package com.jcl.recruit.elasticsearch.resume.logic;

import com.jcl.core.utils.ChannelUtils;
import com.jcl.recruit.elasticsearch.core.constants.ResumeConstant;
import com.jcl.recruit.elasticsearch.resume.dao.ResumeExternalMsgDao;
import com.jcl.recruit.elasticsearch.resume.model.ResumeExternalMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @ClassName ResumeExternalMsgLogic
 * @Author yyliu
 * @Date 2018/10/15 14:05
 * @Version 1.0
 **/
@Component
public class ResumeExternalMsgLogic {

    @Autowired
    private ResumeExternalMsgDao resumeExternalMsgDao;

    public void changeExternalSearchResumeMsg(Integer resumeId,
                                              String from,
                                              String context,
                                              String externalId) {
        ResumeExternalMsg msg = new ResumeExternalMsg();
        msg.setContext(ChannelUtils.encodeResumeExternalMsg(context));
        msg.setSource(from);
        msg.setExternalId(externalId);
        msg.setResumeId(resumeId);
        msg.setCategory(ResumeConstant.RESUME_EXTERNAL_TYPE_SEARCH);
        resumeExternalMsgDao.add(msg);
    }

    public List<ResumeExternalMsg> findListByType(Integer type) {
        return resumeExternalMsgDao.findListByType(type);
    }

    public List<ResumeExternalMsg> findListByResumeIds(List<Integer> resumeIds, Integer type) {
        return resumeExternalMsgDao.findListByResumeIds(resumeIds, type);
    }

    public List<ResumeExternalMsg> findListByResumeId(int resumeId, Integer type) {
        return resumeExternalMsgDao.findListByResumeId(resumeId, type);
    }

    public int add(ResumeExternalMsg resumeExternalMsg) {
        return resumeExternalMsgDao.add(resumeExternalMsg);
    }
}
